<template>
  <a-config-provider :locale="locale">
    <div @mousemove="moveEvent" @click="moveEvent">
      <router-view></router-view>
      <a-modal v-model="visibleExpire" :closable="false" :keyboard="false" :maskClosable="false" width="20%" title="消息" @ok="login" @cancel="quit">
        <template slot="footer"><a-button key="submit" type="primary" @click="login">重新登录</a-button></template>
        <template slot="footer"><a-button key="back" @click="quit">退出</a-button></template>
        <p class="failure">您的会话已过期，您可以选择离开本网站或继续访问</p>
      </a-modal>
    </div>
  </a-config-provider>
</template>

<script>
import zhCN from "ant-design-vue/lib/locale-provider/zh_CN";
export default {
  name: "App",

  data() {
    return {
      locale: zhCN,
      currentTime: new Date().getTime(),
      visibleExpire: false
    };
  },

  created() {},

  methods: {
    moveEvent() {
      let currentTime = this.currentTime;
      let lastTime = new Date().getTime();
      //设置时间 15分钟
      let timeOut = 1000*60*150;
      if (lastTime - currentTime > timeOut) {
        // 未操作页面，跳转登录页面
        this.currentTime = new Date().getTime();
        this.visibleExpire = true
      } else {
        this.currentTime = new Date().getTime();
      }
    },

    login() {
      sessionStorage.setItem('token', '')
      sessionStorage.setItem('orgName', '')
      // sessionStorage.setItem('ipAddress', '')
      // sessionStorage.setItem('indexPermission', '')
      // sessionStorage.setItem('viewPermission', '')
      
      this.$router.push({
          name: 'index'
      })
      location.reload()
    },

    quit() {
      window.opener = null;
      window.open("about:blank", "_self").close();
    },
  },
};
</script>

<style lang="less" src="../src/assets/style/global.less"></style>
<style lang="less" src="../src/assets/style/style.less"></style>
<style>
  /* layer组件-样式修改 */
  .lv-title {
    font-size: 18px;
  }
</style>
